package com.hbd.esdemo.controller;

import com.hbd.esdemo.model.Result;
import com.hbd.esdemo.service.impl.ShipAddressServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 收获地址
 *
 * @author bdhong
 */

@RestController
@AllArgsConstructor
@RequestMapping("/ship-address")
public class ShipAddressController {

    private final ShipAddressServiceImpl shipAddressService;


    /**
     * 不分页查询
     *
     * @param address 地址信息
     * @return
     */
    @GetMapping("/list")
    public Result getShipAddressList(@RequestParam(name = "address", required = false) String address) {
        return Result.buildSuccess(shipAddressService.list(address));
    }


    /**
     * 分页查询
     *
     * @param address 地址信息
     * @return
     */
    @GetMapping("/page")
    public Result getShipAddressPage(String address,
                                     @RequestParam(name = "page", defaultValue = "1", required = false) int page,
                                     @RequestParam(name = "size", defaultValue = "10", required = false) int size) {
        return Result.buildSuccess(shipAddressService.page(address, page, size));
    }
}
